<template>
    <div class="userLogin">
        <div class="inputGroup">
            <div class="input user">
                <div>
                    <i class="bi bi-person-circle mr-3"></i>
                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">用户信息/ Message</small>
                        </div>
                        <input type="text" v-model="userEmail" placeholder="用户邮箱/电话">
                    </div>
                </div>
            </div>
            <div class="input password">
                <div>
                    <i class="bi bi-shield-lock-fill mr-3"></i>
                    <div class="d-inline-block">
                        <div class="mb-1">
                            <small class="text-black-50">用户密码/ Password</small>
                        </div>
                        <input type="password" v-model="userPwd" placeholder="密码">
                    </div>
                </div>
            </div>
        </div>
        <div class="mt-4 ml-4">
            <el-checkbox v-model="radio" label="1">三天免登陆</el-checkbox>
        </div>
        <div class="toSubmit mt-3">
            <el-button round type="warning" @click="Login()">登 录</el-button>
            <el-button round style="margin-left: 1rem" @click="toRoute('/login/toLogin/admin')">管理员登录</el-button>
            <div class="float-right mt-2">
                <el-link type="info" @click="toRoute('/login/toSign')">用户注册</el-link>
            </div>
        </div>
    </div>
</template>

<script>
    import $ from "jquery";

    export default {
        name: "userLogin",
        data(){
            return {
                userEmail:'',
                userPwd:'',
                radio:false
            }
        },
        mounted() {
            this.iconColor()
        },
        methods:{
            Login()
            {
                this.axios
                .post("https://localhost:44347/api/app/p-user/list-user?userEmail="+this.userEmail+"&userPwd="+this.userPwd+"")
                .then(s=>{
                   if(s.data==1)
                   {
                       alert("邮箱登陆成功")
                       this.$router.push('/profile/userMg');
                       localStorage.setItem('name',this.userEmail);
                      localStorage.setItem('pwd',this.userPwd)
                      
                   }
                   else if(s.data==2)
                   {
                       alert("手机号登录成")
                       this.$router.push('/profile/userMg');
                      localStorage.setItem('name',this.userEmail);
                      localStorage.setItem('pwd',this.userPwd)
                   }
                   else
                   {
                       alert("登录失败")
                   }
                })

            },
            toRoute(path){
                this.$router.push(path);
            },
            iconColor(){
                $(".input input").on("focus",function () {
                    $(this).parent().siblings(".bi").addClass("iconColor");
                }).on("blur",function () {
                    $(this).parent().siblings(".bi").removeClass("iconColor")
                })
            }
        },

    }
</script>

<style scoped>

</style>